package com.bianmaba.spring.data.jpa.domain.specification.condition.predicate.generator;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Expression;
import java.lang.reflect.Method;

/**
 * 大于
 * Created by cwx183898 on 2017/12/17.
 */
public class GePredicateGenerator extends AbstractPredicateGenerator {
    protected Method getCreateMethod(CriteriaBuilder builder) {
        Method result = null;
        Method[] methods = builder.getClass().getMethods();
        for (Method method : methods) {
            if (method.getName().equals("greaterThanOrEqualTo")) {
                Class[] types = method.getParameterTypes();
                if (types[0].isAssignableFrom(Expression.class) && !types[1].isAssignableFrom(Expression.class)) {
                    result = method;
                    break;
                }
            }
        }
        return result;
    }
}
